package test2.experiment4.num3;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Practice4_3 {
    enum suit {
        spades, hearts, diamonds, clubs
    }

    enum rank {
        A("ace"), NUM2("2"), NUM3("3"), NUM4("4"), NUM5("5"),
            NUM6("6"), NUM7("7"), NUM8("8"), NUM9("9"),NUM10("10"),
            J("jack"), Q("queen"), K("king");
        private String name;

        private rank(String name) {
            this.name = name;
        }

        public String toValue() {
            return name;
        }
    }

    public static void main(String[] args) {
        int numHands = Integer.parseInt(args[0]);
        int cardsPerHand = Integer.parseInt(args[1]);

        List<String> deck = new ArrayList<>();
        for (suit es : suit.values()) {
            for (rank er : rank.values()) {
                deck.add(er.toValue() + " of " + es);
            }
        }
        Collections.shuffle(deck);
        for (int i = 0; i < numHands; i++) {
            System.out.println(dealHead(deck, cardsPerHand));
        }
    }

    public static List<String> dealHead(List<String> deck, int n) {
        int deckSize = deck.size();
        List<String> handView = deck.subList(deckSize - n, deckSize);
        List<String> hand = new ArrayList<String>(handView);
        handView.clear();
        return hand;
    }
}
